<%@page import="vo.MemberVo"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	request.setCharacterEncoding("utf-8");
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Anodized by FCT</title>

<link rel="stylesheet" type="text/css" href="../css/style.css" />
<link href="http://fonts.googleapis.com/css?family=Arvo"
	rel="stylesheet" type="text/css" />
<link href="http://fonts.googleapis.com/css?family=Bevan"
	rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/httpRequest.js"></script>
<script type="text/javascript">

/* 
function popaddress(option) {
	 if ( option == "c" ) { // 검색된 우편번호와 주소 가져오기
	  theURL = "b.php?option=" + option ;
	  window.open(theURL,"zip","left=100,top=100,width=450,height=300,scrollbars");
	 } else {
	  theURL = "b.php" ;
	  window.open(theURL,"zip","left=100,top=100,width=450,height=300,scrollbars");
	 }
	}
	
 */


//공백제거
function trimSpace(str) {
	var len = str.length;
	for ( var i = 0; i < len; i++) {
		if (str.charAt(i) == " ")
			return 0;
		else
			continue;
	}
	return 1;
}

//주소검색
function searchAddr() {
	window.open("../member/searchaddr2.jsp", "우편번호검색",
			"width=600 ,height=350, scrollbars=yes");
}

//비번힌트 확인
function check(value) {

	//직접입력일경우
	if (value == "in") {
		var td = document.getElementById("td_sel");
		var cnt = td.childNodes.length;
		for ( var i = 0; i < cnt; i++)
			td.removeChild(td.childNodes[0]);

		var u_input = document.createElement("input");
		u_input.setAttribute("type", "text");
		u_input.setAttribute("name", "m_pwd_hint");
		u_input.setAttribute("size", "20");

		td.appendChild(u_input);
		m.m_pwd_hint.focus();
		
	}
}



//form 확인~
function check_saveform() {

	/* var m_pwd = document.getElementById("m_pwd");
	var m_repwd = document.getElementById("m_repwd");
	alert(m_pwd.value); */
	
	if (m.m_pwd.value != m.m_repwd.value) {
		alert(m.m_pwd.value);
		alert("비밀번호가 일치 하지 않습니다.");
		document.m.m_pwd.focus();
		return;
	}
	
	alert(m.m_pwd_hint.value);
	if (m.m_pwd_hint.value == "") {
		alert("비밀번호찾기/힌트를 입력해주세요");
		m.m_pwd_hint.focus();
		return;
	}
	if (m.m_pwd_answer.value == "") {
		alert("비밀번호찾기/답을 입력해주세요");
		m.m_pwd_answer.focus();
		return;
	}

	if (m.m_addr2.value == "") {
		alert("상세주소를 입력해주세요");
		m.m_addr2.focus();
		return;
	}
	
	if (m.phone1.value == "" || m.phone2.value == ""
			|| m.phone3.value == "") {
		alert("전화번호가 입력되지 않았습니다.");
		m.phone1.focus();
		return;
	}
	if (m.m_mail.value == "") {
		alert("메일이 입력되지 않았습니다.");
		document.m.email1.focus();
		return;
	}


	//전화번호
	var phone1 = m.phone1.value;
	var phone2 = m.phone2.value;
	var phone3 = m.phone3.value;
	var m_hp = phone1 + "." + phone2 + "." + phone3;

	m.action = 
		"../member/member_modify.do?m_hp="
			+ m_hp + "&menu_no=2&state=list";

	m.submit();

}


function init(){
	
	if('${mvo.m_sex}'=='man')
		document.getElementById('r1').setAttribute("checked", "checked");
	if('${mvo.m_sex}'=='woman')
		document.getElementById('r2').setAttribute("checked", "checked");
	
	var ph = '${mvo.m_hp}';
	var ph1="";
	var ph2="";
	var ph3="";
	
	for(var i = 0; i<3; i++){
		ph1=ph1 + ph.charAt(i);
	}
	
	for(var i = 4; i<7; i++){
		ph2=ph2 + ph.charAt(i);
	}
	
	for(var i = 9; i<12; i++){
		ph3=ph3 + ph.charAt(i);
	}
	
	document.getElementById('p1').setAttribute("value", ph1);
	document.getElementById('p2').setAttribute("value", ph2);
	document.getElementById('p3').setAttribute("value", ph3);
	
}




</script>	
</head>




<body onload="init();">

	<div>

	<form name="m" method="post">
	<table width="650" align="center" border="0">
				<tr>
					<td colspan="2" align="center"><h1><strong>회원정보</strong></h1></td>
				</tr>
			</table>
			
			<br>
			<br>
				<table border="1" width="650" align="center">
				
					<tr>
						<td class="inform1">이름</td>
						<td class="inform2"><input type="text" id="m_name" name="m_name" value="${mvo.m_name}" readonly>
						</td>
					</tr>
					
					<tr>
						<td class="inform1">아이디</td>
						<td class="inform2"><input type="text" id="m_id" name="m_id" value="${mvo.m_id}" readonly>
						</td>
					</tr>

					<tr>
						<td class="inform1">비밀번호</td>
						<td class="inform2"><input type="password" id="m_pwd"
							name="m_pwd" maxlength="20" size="23" value="${mvo.m_pwd}"></td>
					</tr>

					<tr>
						<td class="inform1">비밀번호확인</td>
						<td class="inform2"><input type="password" id='m_repwd'
							name="m_repwd" maxlength="20" size="23" value="${mvo.m_pwd}"></td>
					</tr>


					<tr>
						<td class="inform1">비밀번호찾기/힌트</td>
						<td  class="inform2" id="td_sel" value="${mvo.m_pwd_hint}"><select
							name="m_pwd_hint" onchange="check(this.value)">
								<option value="one">${mvo.m_pwd_hint}</option>
								<option value="two">비밀번호 힌트 입력하기</option>
								<option value="three">비밀번호 힌트 입력하기</option>
								<option value="four">비밀번호 힌트 입력하기</option>
								<option value="in">직접입력</option>
						</select></td>
					</tr>

					<tr>
						<td class="inform1">비밀번호찾기/답</td>
						<td class="inform2"><input type="text" name="m_pwd_answer" maxlength="20"
							size="20" value="${mvo.m_pwd_answer}" onfocus="this.value=''"></td>
					</tr>

					<!--		<input type="text" onfocus="this.value=''; return true" value="아이디" /> -->

					<tr>
						<td class="inform1">생년월일</td>
						<td  class="inform2"><select name='m_birth_y'>
								<option selected value='${mvo.m_birth_y}'>${mvo.m_birth_y}</option>
								<c:forEach begin="1960" end="2002" step="1" var="year">
									<option value='${year}'>${year}</option>
								</c:forEach>
						</select>년 <select name='m_birth_m'>
								<option selected value='${mvo.m_birth_m}'>${mvo.m_birth_m}</option>
								<c:forEach begin="1" end="12" step="1" var="month">
									<option value='${month}'>${month}</option>
								</c:forEach>
						</select>월 <select name='m_birth_d'>

								<option selected value='${mvo.m_birth_d}'>${mvo.m_birth_d}</option>
								<c:forEach begin="1" end="31" step="1" var="day">
									<option value='${day}'>${day}</option>
								</c:forEach>
						</select>일&nbsp;&nbsp;
					</tr>


					<tr>
							<td class="inform1">성&nbsp;&nbsp;&nbsp;&nbsp;별</td>

							<td class="inform2">남 
							<input id="r1" type="radio"
								name="m_sex" value='man' >&nbsp; 여 
							<input
								id="r2" type="radio" name="m_sex" value='woman'>
							</td>
						</tr>


						<tr>
						<td class="inform1">이&nbsp;&nbsp;메&nbsp;&nbsp;일</td>
						<td class="inform2"><input type="text"
							name="m_mail" size="40" value="${mvo.m_mail}">
					</tr>

					<tr>
						<td class="inform1">핸드폰번호</td>
						<td  class="inform2"><select name="phone1" id="p1">
								<option>010</option>
								<option>011</option>
								<option>016</option>
								<option>017</option>
								<option>018</option>
								<option>019</option>
						</select> - <input type="text" name="phone2" id="p2" maxlength="4" size="4">
							- <input type="text" name="phone3" maxlength="4" size="4" id="p3"></td>
					</tr>


					<tr>
						<td class="inform1">별&nbsp;&nbsp;&nbsp;&nbsp;명</td>
						<td  class="inform2"><input type="text" id="m_alias" name="m_alias" value="${mvo.m_alias}" readonly>
						</td>
					</tr>


					<tr>
						<td class="inform1">우편번호</td>
						<td class="inform2">
						
						 <input type="text"
							name="m_zipcode" readonly="readonly" value='${mvo.m_zipcode}'
							maxlength="3" size="10"> <input type="button"
							value="주소 검색" onclick="javascript:popaddress()"></td> 
					</tr>

					<tr>
						<td class="inform1">집&nbsp;&nbsp;주&nbsp;&nbsp;소</td>
						<td class="inform2"><input type="text"
							name="m_addr1" readonly="readonly" size="50" value="${mvo.m_addr1}"></td>
					</tr>

					<tr>
						<td class="inform1">상세주소</td>
						<td class="inform2"><input type="text"
							name="m_addr2" size="50" value="${mvo.m_addr2}"></td>
					</tr>

					<tr>
						<td  class="inform2" colspan="2" align="center">
						<input type="button" class="pink_button"
							onclick="check_saveform()" value="회원정보변경">&nbsp;&nbsp; <input
							class="pink_button" type="reset" value="다시작성"></td>
					</tr>
					
				</table>
		
		
		
			</form>
</div>
	
	
</body>
</html>